package com.tencent.welink.api.base;

import com.tencent.welink.api.OpenApiTokenChange;
import com.tencent.welink.config.BussinessConfig;
import com.tencent.welink.util.TicketData;
import org.apache.http.entity.ContentType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * Created by junchihe on 2020/6/4.
 */
public abstract class WelinkOpenApi extends Api {
    private static final Logger log = LogManager.getLogger(WelinkOpenApi.class);

    public WelinkOpenApi(String httpPreFix, boolean isGet) {
        super(httpPreFix, isGet);
    }

    public WelinkOpenApi(String httpPreFix, boolean isGet, ContentType contentType) {
        super(httpPreFix, isGet,contentType);
    }

    /**
     * 获取URL，自动添加公有参数：iotim_ticket，token
     * @return
     */
    public String getUrl() {
        String url = BussinessConfig.httpProtocal+ BussinessConfig.httpDomain + httpPreFix;
        TicketData ticketData = OpenApiTokenChange.getTicketData();
        return new StringBuilder(url).append("?").append("iotim_ticket=").append(ticketData.iotim_ticket).append("&token=").append(ticketData.token).toString();
    }

    public abstract void displayResult(String result);
}






